//
//  CountdownManager.h
//  计时器
//
//  Created by lu liu on 16/6/22.
//  Copyright © 2016年 nationz. All rights reserved.
//

#import <Foundation/Foundation.h>
#import <UIKit/UIKit.h>

@class CountdownTask;

@interface CountdownManager : NSObject

@property (nonatomic, strong) NSOperationQueue *pool;

+ (instancetype)defaultManager;

- (void)schedulCountDownWithKey:(NSString *)aKey timeInterval:(NSTimeInterval)timeInterval countingDown:(void(^)(NSTimeInterval leftTimeInterval))countingDown finished:(void(^)(NSTimeInterval finalTimeInterval))finished;

- (void)closeCountDownWithKey:(NSString *)aKey;

- (BOOL)countdownTaskExistWithKey:(NSString *)aKey task:(CountdownTask *__autoreleasing *)task;

@end


@interface CountdownTask : NSOperation

@property (copy, nonatomic) void(^countingDownBlock)(NSTimeInterval timeInterval);

@property (copy, nonatomic) void(^finishBlock)(NSTimeInterval timeInterval);

@property (assign, nonatomic) NSTimeInterval leftTimeInterval;

@property (assign, nonatomic) UIBackgroundTaskIdentifier taskIdentifier;

@property (strong, nonatomic) NSString *operationName;

@end
